<?php

/**
 * Gets all contacts
 * @package ModuleOrganisationCommunication
 * @version 1.0b
 * @return table
 */

session_start();

// Configuration file
include '../configuration.php';
// Functions
include '../inc/functions.php';

// Checking if user is logged in
if (!CheckSession()):
	exit();
endif;

// Include all objects
// TODO: Include only needed classes
foreach (glob($configuration['webroot'].'objects/*.php') as $class) { include_once $class; }

$contact = new Contact();
$contactList = $contact->GetList(Array(Array('contactId', '>', '0')), 'lastname'); ?>

<table cellpadding="0" cellspacing="0" border="0" class="table-objects">
	<tr>
		<th class="check"></th>
		<th>#</th>
		<th>Nom</th>
		<th>E-mail</th>
	</tr>
	<?php foreach ($contactList as $contact) {
		$res  = '<tr>';
		$res .= '<td class="check"><input name="all" type="radio" value="'.$contact->contactId.'"'.(($_POST['id'] == $contact->contactId) ? ' checked="checked"' : '').' /></td>';
		$res .= '<td>'.$contact->contactId.'</td>';
		$res .= '<td><span id="contact-'.$contact->contactId.'">'.$contact->lastname.' '.$contact->firstname.'</span></td>';
		$res .= '<td>'.$contact->email.'</td>';
		$res .= '</tr>';
		echo $res;
	} ?>
</table>